package cn.tp.ksoft.civil_driver.dialog;

import android.content.Context;
import android.util.SparseArray;
import android.view.View;

import cn.tp.ksoft.civil_driver.R;

/**
 * Created by zhusong on 16/5/2.
 */
public class ConfirmDurationDialog extends WheelDialog {
    private final int DEFAULT_MAX_DAY = 31;
    private final int DEFAULT_MAX_HOUR = 24;

    public ConfirmDurationDialog(Context context) {
        super(context);
    }

    @Override
    protected void initData() {
        mWheel1.setVisibility(View.VISIBLE);
        mWheel2.setVisibility(View.VISIBLE);
        mWheel3.setVisibility(View.GONE);
        mTitleTv.setText(getContext().getString(R.string.driver_order_use_car_duration));
        SparseArray<String> days = new SparseArray<>();
        for (int i = 0; i <= DEFAULT_MAX_DAY; i++) {
            days.put(i, getContext().getString(R.string.driver_date_day, i));
        }
        mWheelAdapter1.setData(days);

        SparseArray<String> hours = new SparseArray<>();
        for (int i = 0; i < DEFAULT_MAX_HOUR; i++) {
            hours.put(i, getContext().getString(R.string.driver_date_hour, i));
        }
        mWheelAdapter2.setData(hours);
    }

    @Override
    protected void onPositiveClick() {
        if (null != mCallBack) {
            mCallBack.onPositiveClick(mWheelAdapter1.getKey(mWheel1.getCurrentItem()),
                    mWheelAdapter2.getKey(mWheel2.getCurrentItem()));
        }
    }
}
